<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<link href="${pageContext.request.contextPath}/mycss/button.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/mycss/select.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/mycss/font.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/showdiv.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>

<title>添加学生</title>
<script type="text/javascript">
	function subForm() {
		if ($('#myform').form('validate')) {

			var filepath = $("#filepath").val();
			alert(filepath);
			$.ajax({
				url : 'excleImport',
				typs : "post",
				data : {
					"filepath" : filepath
				},
				async : false,
			});

			var filepath = $("#filepath").val();
			var re = /(\\+)/g;
			var filename = filepath.replace(re, "#");
			//对路径字符串进行剪切截取 
			var one = filename.split("#");
			//获取数组中最后一个，即文件名 
			var two = one[one.length - 1];
			//再对文件名进行截取，以取得后缀名 
			var three = two.split(".");
			//获取截取的最后一个字符串，即为后缀名 
			var last = three[three.length - 1];
			//添加需要判断的后缀名类型 
			var tp = "xls";
			//返回符合条件的后缀名在字符串中的位置 
			var rs = tp.indexOf(last);
			if (rs != -1) {
				$("#myform").attr("action", "UploadStuPerInfo");
				$("#myform").submit();
			} else {
				alert("您选择的上传文件不是有效xls文件！");
				return false;
			}
		} else {
			alert("请选择上传文件！");
		}
	}

	$().ready(function() {
		// 在键盘按下并释放及提交后验证提交表单
		$("#signupForm").validate({
			rules : {
				stId : "required",
				stName : "required",
				stAge : "required",
				stTel : "required",
				stDept : "required",
				stAddress : "required",
			},
			messages : {
				stId : "请输入学号",
				stName : "请输入姓名",
				stAge : "请输入年龄",
				stTel : "请输入电话号码",
				stDept : "请输入系别",
				stAddress : "请输入地址",
			}
		});
	});
</script>
<style type="text/css">
.error {
	color: red;
}

span {
	font: 10px;
	font-weight: bold;
	color: black;
}

.form-signin {
	max-width: 550px;
	padding: 19px 29px 29px;
	margin: 0 auto;
	background-image: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%);
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}


.form-signin .form-signin-heading, .form-signin {
	margin-bottom: 2px;
}

.form-signin input[type="text"] {
	font-size: 16px;
	height: auto;
	margin-bottom: 15px;
	padding: 7px 9px;
}
#model {
	position: fixed;
	width: 600px;
	height: 200px;
	top: 48%;
	left: 35%;
	margin: 0 auto;
	-webkit-perspective: 600px;
	-moz-perspective: 600px;
	perspective: 600px;
	text-indent: 2em;
	font-family: "微软雅黑";
	line-height: 25px;
	padding: 15px;
	background-image: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%);
	background-blend-mode: multiply, multiply;
	opacity: 0;
	-webkit-transition: all .51s ease-in;
	-moz-transition: all .51s ease-in;
	transition: all .51s ease-in;
	visibility: hidden;
	margin-top: -100px;
	margin-left: -100px;
}

#model.move {
	opacity: 1;
	visibility: visible;
}

.a_btn {
	width: 70px;
	border: none;
	padding: 0.6em 1.2em;
	background: #AFFFFF;
	color: #EE0000;
	font-family: "微软雅黑";
	font-size: 1em;
	letter-spacing: 1px;
	text-transform: uppercase;
	cursor: pointer;
	display: inline-block;
	margin: 7px 2px;
	border-radius: 2px;
}

.a_btn:hover {
	background: #AEEEEE;
	text-decoration: none;
} /*指鼠标在链接*/
.a_btn:link {
	text-decoration: none;
} /* 指正常的未被访问过的链接*/
.overlay {
	position: fixed;
	width: 100%;
	height: 100%;
	visibility: hidden;
	top: 0;
	left: 0;
	z-index: 1000;
	opacity: 0;
	background: #AEEEEE;
	-webkit-transition: all 0.3s;
	-moz-transition: all 0.3s;
	transition: all 0.3s;
}
</style>
</head>
<body>
	<form class="form-signin" action="addStudent" id="signupForm"
		method="post">
		<legend>个人信息表</legend>
		<p style="display: block;text-align: center;">
			<input class="input" type="text" name="stId" id="stId" minlength="12"
				maxlength="12" placeholder="学号">
		</p>
		<p style="display: block;text-align: center;">
			<input class="input" type="text" name="stName" id="stName"
				placeholder="姓名">
		</p>
		<p style="display: block;text-align: center;">
			<label for="man" class="radio"> <span class="radio-bg"></span>
				<input type="radio" name="stSex" id="man" value="男"
				onblur="checkstSex()"> 男 <span class="radio-on"></span> <!-- 选中则用一个白点覆盖 -->
			</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label
				for="woman" class="radio"> <span class="radio-bg"></span> <input
				type="radio" name="stSex" id="woman" value="女" onblur="checkstSex()">
				女 <span class="radio-on"></span>
			</label>
		</p>

		<p style="display: block;text-align: center;">
			<input class="input" type="number" name="stAge" id="stAge" min="0"
				max="100" placeholder="年龄">
		</p>
		<p style="display: block;text-align: center;">
			<input class="input" type="text" name="stTel" id="stTel"
				maxlength="11" placeholder="电话号码">
		</p>
		<p style="display: block;text-align: center;">
			<input class="input" type="text" name="stDept" id="stDept"
				placeholder="系别">
		</p>
		<p style="display: block;text-align: center;">
			<input class="input" type="text" name="stAddress" id="stAddress"
				placeholder="地址">
		</p>

		<div align="center">
			<input type="submit" value="提交" class="button red">
			&nbsp;&nbsp;&nbsp; <input type="button"
				onclick="window.location.href='userMain.jsp'" value="返回"
				class="button white">
		</div>
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <a
			href="javascript:void(0);" id="btnout" class="a_btn"
			onclick="opendiv('btnout','#model')">批量导入</a>
	</form>

	<div id="model">
		<font color="red">注意：导入的excel表格需按要求写。信息非空！excel表格名称默认为“Sheet1”<br> 第一行:STID;
			STNAME; STSEX; STAGE; STTEL; STDEPT; STADDRESS; STGROUP; PASSWORD<br>
			第二行:各个学生的数据。
			<br>
			<br>
			<br>
		</font>
		<form id="myform" method="post" enctype="multipart/form-data">
			<table>
				<tr>
					<td></td>
					<td><input type="file" name="filepath" id="filepath"
						class="easyui-validatebox" required=true
						validType="equalLength[4]" missingMessage="文件!" value="" /></td>
					<td><a id="btn1" class="button red"
						data-options="iconCls:'icon-ok'" style="width: 60px"
						onclick="subForm();">上传</a></td>
				</tr>
			</table>
		</form>
		<div align="right">
			<button id="btnin" class="button white"
				onclick="closediv('btnin','#model')">关闭</button>
		</div>
	</div>

	<!-- the overlay element -->
	<div class="overlay" id="overlay"></div>
</body>
</html>
